package com.apes.scm.masterdata.stock.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.soe.metadata.BusinessType;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：库区属性业务单据配置
 *
 * @author HuJianlin
 * @create 2018-03-14 15:55
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = "mas_usage_business")
public class UsageBusiness extends BaseModel {

    @Id
    @Column(name = "id", length = 8 )
    @ApesGenerator(code = "mas_usage_business", name = "库区属性单据业务编码")
    @Comment("编码")
    private String id;  //编码

    @ManyToOne(optional = false)
    @JoinColumn(name = "usage_id", referencedColumnName = "id", nullable = true)
    @Comment("库区属性编码")
    private StockUsage usage; //库区属性编码

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "business_type_id", referencedColumnName = "id")
    @Comment("单据类型编码")
    private BusinessType businessType;  //单据类型


    @Column(name = "valid", nullable = false, columnDefinition = "number(1,0) default 0")
    @Comment("有效")
    private boolean valid; //有效
}
